package com.eascs.afterloan.controller;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.text.DecimalFormat;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.alibaba.dubbo.config.annotation.Reference;
import com.eascs.admin.api.form.O2oAfterLoanForm;
import com.eascs.admin.common.controller.BaseMasterViewController;
import com.eascs.admin.common.excel.ExcelService;
import com.eascs.admin.o2o.credit.service.CreditReportService;
import com.eascs.admin.o2o.detail.form.ShowDetailForm;
import com.eascs.admin.o2o.enterpriseZX.entity.O2oEnterpriseZxEntity;
import com.eascs.admin.o2o.enterpriseZX.service.O2oEnterpriseZxService;
import com.eascs.admin.o2o.internal.service.AuditCommentService;
import com.eascs.admin.o2o.internal.util.BaseUtils;
import com.eascs.admin.o2o.loan.entity.O2oLoanUserEntity;
import com.eascs.admin.o2o.loan.entity.O2oLoanapplyEntity;
import com.eascs.admin.o2o.loan.service.O2oLoanUserService;
import com.eascs.admin.o2o.loan.service.O2oLoanapplyService;
import com.eascs.afterloan.service.O2oAfterService;
import com.eascs.app.dao.PageResult;
import com.eascs.common.doc.excel.DefaultRowWriteHandler;
import com.eascs.common.doc.excel.ExcelApiHelper;
import com.eascs.common.exception.RuntimeIOException;
import com.eascs.common.util.IoUtil;
import com.eascs.common.util.UrlUtil;
import com.eascs.crm.common.service.ICustomerInfoService;
import com.eascs.datalist.service.O2oDataListService;
import com.eascs.loan.service.O2oPaymentsService;
import com.eascs.site.page.PaginationInfo;
import com.eascs.site.page.SelectDataOption;
import com.eascs.site.view.ViewContext;
import com.eascs.site.view.button.Button;
import com.eascs.site.view.button.ButtonHelper;
import com.eascs.tag.MenuTag;
import com.eascs.workflow.common.entity.sys.ActOrgEntity;
import com.eascs.workflow.common.service.sys.SysOrgService;
import com.eascs.workflow.common.type.SystemModule;

@Controller
@RequestMapping("/afterloan")
public class O2oAfterLoanController extends BaseMasterViewController {


	@Reference
	ICustomerInfoService iCustomerInfoService;

	@Autowired
	private O2oLoanapplyService loanService;

	@Autowired
	CreditReportService creditReportService;

	@Inject
	O2oPaymentsService o2oPaymentsService;

	@Autowired
	private AuditCommentService auditCommentService;

	@Value("${o2o.admin.iframe.domain}")
	private String domain;

	@Autowired
	O2oAfterService service;

	@Reference
	SysOrgService sysOrgService;
	
	@Autowired
	O2oDataListService o2oDataListService;
	@Value("${o2o.admin.excelExport.AfterLoan}")
	private String excelExportAfterLoan;

	@Value("${o2o.admin.afterloan.oldUrl}")
	private String afterloanOldUrl;

	@RequestMapping("/index")
	public String index(O2oAfterLoanForm entity) {
		ViewContext.put(MenuTag.CURRENT_MENU_CODE, "afterLoanFind");
		String o2ourl = "/rafterloan/o2o";
		String reporto2ourl = "/afterloan/download";
		
		List<ActOrgEntity> orgProvince = sysOrgService.getOrgProvince();
		ViewContext.put("ActOrgEntitys", orgProvince);
		if (entity != null) {
			String billCode = entity.getBillCode() == null ? "" : entity.getBillCode();
			String bankLoan = entity.getBankLoan() == null ? "" : entity.getBankLoan();
			String operName = entity.getOperName() == null ? "" : entity.getOperName();
			String loanUserName = entity.getLoanUserName() == null ? "" : entity.getLoanUserName();
			String loanDateStart = entity.getLoanDateStart() == null ? null : entity.getLoanDateStart();
			String loanDateEnd = entity.getLoanDateEnd() == null ? null : entity.getLoanDateEnd();
			String createUserName = entity.getCreateUserName() == null ? "" : entity.getCreateUserName();
			String createDateStart = entity.getCreateDateStart() == null ? null : entity.getCreateDateStart();
			String createDateEnd = entity.getCreateDateEnd() == null ? null : entity.getCreateDateEnd();
			String loanType = entity.getLoanType() == null ? "" : entity.getLoanType();
			String ltd = entity.getLtd() == null ? "" : entity.getLtd();
			String ltdName = entity.getLtdName() == null ? "" : entity.getLtdName();
			String province = entity.getProvince() == null ? "" : entity.getProvince();
			String gdStatus = entity.getGdStatus() == null ? "" : entity.getGdStatus();
			String repaystatus = entity.getRepaystatus() == null ? "" : entity.getRepaystatus();
			String dateDueStart = entity.getDateDueStart() == null ? null : entity.getDateDueStart();
			String dateDueEnd = entity.getDateDueEnd() == null ? null : entity.getDateDueEnd();
			String idc = entity.getIdc() == null ? null : entity.getIdc();
			String regionalName = entity.getRegionalName() == null ? "" : entity.getRegionalName();
			String brandName = entity.getBrandName() == null ? "" : entity.getBrandName();
			String partnerName = entity.getPartnerName() == null ? "" : entity.getPartnerName();
			String hostProvince=entity.getHostProvince()==null?"":entity.getHostProvince();
			String firstLoanStartTime = entity.getFirstLoanStartTime() == null ? null : entity.getFirstLoanStartTime();
			String firstLoanEndTime = entity.getFirstLoanEndTime() == null ? null : entity.getFirstLoanEndTime();
			o2ourl = UrlUtil.appendUrl(o2ourl, "firstLoanStartTime", firstLoanStartTime);
			o2ourl = UrlUtil.appendUrl(o2ourl, "firstLoanEndTime", firstLoanEndTime);
			o2ourl = UrlUtil.appendUrl(o2ourl, "billCode", billCode);
			o2ourl = UrlUtil.appendUrl(o2ourl, "bankLoan", bankLoan);
			o2ourl = UrlUtil.appendUrl(o2ourl, "operName", operName);
			o2ourl = UrlUtil.appendUrl(o2ourl, "loanUserName", loanUserName);
			o2ourl = UrlUtil.appendUrl(o2ourl, "loanDateStart", loanDateStart);
			o2ourl = UrlUtil.appendUrl(o2ourl, "loanDateEnd", loanDateEnd);
			o2ourl = UrlUtil.appendUrl(o2ourl, "createUserName", createUserName);
			o2ourl = UrlUtil.appendUrl(o2ourl, "createDateStart", createDateStart);
			o2ourl = UrlUtil.appendUrl(o2ourl, "createDateEnd", createDateEnd);
			o2ourl = UrlUtil.appendUrl(o2ourl, "dateDueStart", dateDueStart);
			o2ourl = UrlUtil.appendUrl(o2ourl, "dateDueEnd", dateDueEnd);
			o2ourl = UrlUtil.appendUrl(o2ourl, "ltdName", ltdName);
			o2ourl = UrlUtil.appendUrl(o2ourl, "ltd", ltd);
			o2ourl = UrlUtil.appendUrl(o2ourl, "loanType", loanType);
			o2ourl = UrlUtil.appendUrl(o2ourl, "province", province);
			o2ourl = UrlUtil.appendUrl(o2ourl, "gdStatus", gdStatus);
			o2ourl = UrlUtil.appendUrl(o2ourl, "repaystatus", repaystatus);
			o2ourl = UrlUtil.appendUrl(o2ourl, "idc", idc);
			o2ourl = UrlUtil.appendUrl(o2ourl, "regionalName", regionalName);
			o2ourl = UrlUtil.appendUrl(o2ourl, "brandName", brandName);
			o2ourl = UrlUtil.appendUrl(o2ourl, "partnerName", partnerName);
			o2ourl = UrlUtil.appendUrl(o2ourl, "hostProvince", hostProvince);
			// UrlUtil.resetParam(RequestContext.getRequestUrlWithQueryString(),
			// "pageOldIndex", "")
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "firstLoanStartTime", firstLoanStartTime);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "firstLoanEndTime", firstLoanEndTime);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "billCode", billCode);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "bankLoan", bankLoan);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "operName", operName);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "loanUserName", loanUserName);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "loanDateStart", loanDateStart);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "loanDateEnd", loanDateEnd);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "createUserName", createUserName);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "createDateStart", createDateStart);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "createDateEnd", createDateEnd);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "dateDueStart", dateDueStart);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "dateDueEnd", dateDueEnd);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "ltdName", ltdName);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "ltd", ltd);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "loanType", loanType);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "province", province);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "gdStatus", gdStatus);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "repaystatus", repaystatus);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "idc", idc);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "regionalName", regionalName);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "brandName", brandName);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "partnerName", partnerName);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "hostProvince", hostProvince);
			o2ourl = o2ourl + "&oaIndex=";
			o2ourl = o2ourl + "&o2oIndex=";
			if (entity.getMenutype()!=null) {
				ViewContext.put(MenuTag.CURRENT_MENU_CODE, entity.getMenutype());
			}
		} else {
			o2ourl = o2ourl + "?o2oIndex=";
		}
		ViewContext.put("o2ourl", o2ourl);
		ViewContext.put("reporto2ourl", reporto2ourl);
		ViewContext.put("vo", entity);
		return "afterloan/index";
	}

	@RequestMapping(value = "/detail", method = RequestMethod.GET)
	public String showDetail(ShowDetailForm showDetailForm) {
		return "redirect:/detail?billCode=" + showDetailForm.getBillCode();
	}

	/**
	 * 附件列表
	 */
	public void queryDatalist(String loanapplyNo) {
		PageResult<Object[]> pageResult = loanService.findO2oDataListEntityById(loanapplyNo);
		String titles[] = { "附件类型", "文件名", "提交人", "提交时间", "更新时间" };
		Button[] titleButtons = new Button[] { null, ButtonHelper.createOpenButton(null, "/file/download?datalistno=") };
		PaginationInfo datalistInfo = new PaginationInfo(pageResult, titles, "/loanUser/loanudpate");
		datalistInfo.setTitleButtons(titleButtons);
		datalistInfo.setBuildPagingNavigation(false);
		datalistInfo.setFirstRenderColumnIndex(1);
		datalistInfo.setBuildRowNumber(true);
		ViewContext.put("datalistInfo", datalistInfo);
	}

	/**
	 * 内审历史列表
	 * 
	 * @param loanapplyNo
	 */
	public void queryInternalList(String loanapplyNo) {
		PageResult<Object[]> auditResult = auditCommentService.findAuditList(loanapplyNo);
		String title[] = { "EA批复额度", "综合费率", "送审银行", "贷款用途", "审批期限", "审批还款方式", "风险补偿金利率", "审批保证金费率", "审批管理费费率", "审批人", "审批时间", "备注" };
		PaginationInfo auditInfo = new PaginationInfo(auditResult, title);
		SelectDataOption[] selectDataOptions = { null, null, new SelectDataOption("BANKTYPEO2O"), new SelectDataOption("PAYMENTTYPE"), new SelectDataOption("OTOLOANTERM"), new SelectDataOption("OTOREPAYMENTWAY"), null, new SelectDataOption("O2ORISKDEPOSITFEERATE"), new SelectDataOption("O2ODEPOSITFEERATE"), new SelectDataOption("O2OMANAGEFEERATE"), null, null, null };
		auditInfo.setSelectDataOptions(selectDataOptions);
		auditInfo.setBuildPagingNavigation(false);
		auditInfo.setFirstRenderColumnIndex(0);
		auditInfo.setBuildRowNumber(true);
		auditInfo.setFormats(new Format[] { new DecimalFormat(",##0.00"), null, null, null, null, null, null, null, null, null, null, null });
		ViewContext.put("auditResult", auditInfo);
	}

	@RequestMapping("/download")
	public void dowanload(O2oAfterLoanForm entity, HttpServletResponse httpServletResponse, HttpServletRequest request) {
		entity.setPageSize(8000);
		PageResult<Object[]> pageResult = service.getO2oAfterLoanExport(entity);
		String path = O2oAfterLoanController.class.getResource("/excelTemplate").getPath();
		StringBuffer s = new StringBuffer();
		String outPath = s.append(path).append("/AfterLoan-model.xls").toString();
		OutputStream os = null;
		try {
			String outfile = "贷后数据.xls";
			String userAgent = request.getHeader("User-Agent");
			byte[] bytes = userAgent.contains("MSIE") ? outfile.getBytes() : outfile.getBytes("UTF-8");
			outfile = new String(bytes, "ISO-8859-1"); // 各浏览器基本都支持ISO编码
			File f = new File(outPath);
			if (!f.exists())
				throw new RuntimeIOException("file not found");
			os = httpServletResponse.getOutputStream();
			httpServletResponse.reset();
			httpServletResponse.setHeader("Content-Disposition", "attachment; filename=" + outfile);
			httpServletResponse.setContentType("application/octet-stream; charset=utf-8");
			DefaultRowWriteHandler defaultRowWriteHandler = new DefaultRowWriteHandler(pageResult.getData());
			ExcelApiHelper.writeHandle(httpServletResponse.getOutputStream(), O2oAfterLoanController.class.getResourceAsStream("/excelTemplate/AfterLoan-model.xls"), defaultRowWriteHandler);
			ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
			IoUtil.fileToOutputStream(f, byteArrayOutputStream);
			os.write(byteArrayOutputStream.toByteArray());
			os.flush();
			os.close();
		} catch (Exception e) {
			throw new RuntimeIOException(e);
		} finally {
			IoUtil.close(os);
		}
	}

	// 先生成文件然后在读这个文件
	public String saveAfterLoan(List<Object[]> data) {
		// 模板
		String soucreFileName = "/excelTemplate/AfterLoan-model.xls";
		// 输出路径
		String path = O2oAfterLoanController.class.getResource("/excelTemplate").getPath();
		StringBuffer s = new StringBuffer();
		String outPath = s.append(path).append("/AfterLoan.xls").toString();

		int col = 16;
		// 需要统计的列
		int[] arr = { 8 };
		String title = "贷后数据";
		// 开始的表格，行，列
		int sheetIndex = 0;
		int rowIndex = 1;
		int columnIndex = 0;
		// 生产excel
		new ExcelService().writeByDate(soucreFileName, outPath, col, arr, Arrays.asList(title), sheetIndex, rowIndex, columnIndex, data);
		// 存放的文件的文件夹
		return path + "/" + outPath;
	}

	@RequestMapping("/due-warning-10")
	public String warning10() {
		Date t2 = new Date();
		GregorianCalendar gc = new GregorianCalendar();
		gc.setTime(t2);
		gc.add(5, 9);
		SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
		String old_date = f.format(gc.getTime());
		String now_date = f.format(t2);
		return "redirect:/afterloan/index?dateDueStart=" + now_date + "&dateDueEnd=" + old_date+"&menutype=afterOnlyTen";
	}

	@RequestMapping("/due-warning-5")
	public String warning5() {
		Date t2 = new Date();
		GregorianCalendar gc = new GregorianCalendar();
		gc.setTime(t2);
		gc.add(5, 4);
		SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
		String old_date = f.format(gc.getTime());
		String now_date = f.format(t2);
		return "redirect:/afterloan/index?dateDueStart=" + now_date + "&dateDueEnd=" + old_date+"&menutype=afterOnlyFive";
	}

	/**
	 * @Title: credit
	 * @Description: 征信查询
	 * @author 张庆奇
	 * @param entity
	 * @return
	 * @return String
	 * @throws @date
	 *             2017年2月4日 下午2:13:01
	 */
	@RequestMapping("/credit")
	public String credit(O2oAfterLoanForm entity) {
		ViewContext.put(MenuTag.CURRENT_MENU_CODE, "credit");
		String o2ourl = "/rafterloan/credit";
		String reporto2ourl = "/afterloan/downloadCredit";
		if (entity != null) {

			String createDateStart = entity.getCreateDateStart() == null ? null : entity.getCreateDateStart();
			String createDateEnd = entity.getCreateDateEnd() == null ? null : entity.getCreateDateEnd();
			String province = entity.getProvince() == null ? "" : entity.getProvince();
			String coopereBank = entity.getCoopereBank() == null ? "" : entity.getCoopereBank();
			String billCode = entity.getBillCode() == null ? "" : entity.getBillCode();
			o2ourl = UrlUtil.appendUrl(o2ourl, "createDateStart", createDateStart);
			o2ourl = UrlUtil.appendUrl(o2ourl, "createDateEnd", createDateEnd);
			o2ourl = UrlUtil.appendUrl(o2ourl, "coopereBank", coopereBank);
			o2ourl = UrlUtil.appendUrl(o2ourl, "province", province);
			o2ourl = UrlUtil.appendUrl(o2ourl, "billCode", billCode);
			o2ourl = o2ourl + "&oaIndex=";
			o2ourl = o2ourl + "&o2oIndex=";
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "createDateStart", createDateStart);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "createDateEnd", createDateEnd);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "coopereBank", coopereBank);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "province", province);
			reporto2ourl = UrlUtil.appendUrl(reporto2ourl, "billCode", billCode);

		} else {
			o2ourl = o2ourl + "?o2oIndex=";
		}
		ViewContext.put("o2ourl", o2ourl);
		ViewContext.put("reporto2ourl", reporto2ourl);
		ViewContext.put("vo", entity);
		return "afterloan/credit";
	}

	@RequestMapping("/downloadCredit")
	public void downloadCredit(O2oAfterLoanForm entity, HttpServletResponse httpServletResponse, HttpServletRequest request) {
		entity.setPageSize(Integer.MAX_VALUE);
		PageResult<Object[]> pageResult = o2oDataListService.getCreditByPage(entity);
		String path = O2oAfterLoanController.class.getResource("/excelTemplate").getPath();
		StringBuffer s = new StringBuffer();
		String outPath = s.append(path).append("/credit-model.xls").toString();
		OutputStream os = null;
		try {
			String outfile = "征信报告数据.xls";
			String userAgent = request.getHeader("User-Agent");
			byte[] bytes = userAgent.contains("MSIE") ? outfile.getBytes() : outfile.getBytes("UTF-8");
			outfile = new String(bytes, "ISO-8859-1"); // 各浏览器基本都支持ISO编码
			File f = new File(outPath);
			if (!f.exists())
				throw new RuntimeIOException("file not found");
			os = httpServletResponse.getOutputStream();
			httpServletResponse.reset();
			httpServletResponse.setHeader("Content-Disposition", "attachment; filename=" + outfile);
			httpServletResponse.setContentType("application/octet-stream; charset=utf-8");
			DefaultRowWriteHandler defaultRowWriteHandler = new DefaultRowWriteHandler(pageResult.getData());
			ExcelApiHelper.writeHandle(httpServletResponse.getOutputStream(), O2oAfterLoanController.class.getResourceAsStream("/excelTemplate/credit-model.xls"), defaultRowWriteHandler);
			ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
			IoUtil.fileToOutputStream(f, byteArrayOutputStream);
			os.write(byteArrayOutputStream.toByteArray());
			os.flush();
		} catch (IOException e) {
			throw new RuntimeIOException(e);
		} finally {
			IoUtil.close(os);
		}
	}

	/**
	 * @author CXW
	 * @describe  loan-13095 贷后管理增加贷后回检功能 ,查询列表
	 * @param entity
	 * @date 2018-03-01 16:12
	 * @return
	 */
	@RequestMapping("/pick_index")
	public String afterLoanPickIndex(O2oAfterLoanForm entity) {
		entity.setPageSize(10);
		ViewContext.put(MenuTag.CURRENT_MENU_CODE, "afterLoanPickFind");
		String o2ourl = "/afterloan/pick_index";
		String billCode = entity.getBillCode() == null ? "" : entity.getBillCode();
		String loanUserName = entity.getLoanUserName() == null ? "" : entity.getLoanUserName();
		o2ourl = UrlUtil.appendUrl(o2ourl, "billCode", billCode);
		o2ourl = UrlUtil.appendUrl(o2ourl, "loanUserName", loanUserName);
		o2ourl = o2ourl + "&o2oIndex=";
		PageResult<Object[]> pageResult = service.findArchive_QueryByPage(entity);//
		String titles[] = { "贷款单号", " 借款人姓名", "信贷经理", "放款银行", "经营平台", "省区", "贷款类型", "放款金额(万元)", "放款日期", "到期日期 ", "还款状态" };
		Button[] titleButtons = new Button[] { ButtonHelper.createOpenButton(null, "/afterloan/pick_detail?loanapplyNo=") };// 详情按钮
		// //billCode前面还有个主键
		SelectDataOption[] selectDataOptions = { null, null, null, new SelectDataOption("BANKTYPEO2O"), null, null, new SelectDataOption("OTO_LOAN_TYPE"), null, null, null, new SelectDataOption("HKZT") };

		PaginationInfo o2oPagingInfo = new PaginationInfo(pageResult, titles, o2ourl);
		o2oPagingInfo.setBuildPagingNavigation(true);
		o2oPagingInfo.setFirstRenderColumnIndex(1);
		// 设置详情按钮
		if (entity.getMenutype() == null) {
			o2oPagingInfo.setTitleButtons(titleButtons);
		}
		o2oPagingInfo.setSelectDataOptions(selectDataOptions);
		o2oPagingInfo.setFormats(new Format[] { null, null, null, null, null, null, null, new DecimalFormat(",##0.00"), null, null, null });
		ViewContext.put("o2oPagingInfo", o2oPagingInfo);
		ViewContext.put("vo", entity);
		return "afterloan/after_loan_pick_index";
	}
	
	
	@Autowired
	private O2oEnterpriseZxService o2oEnterpriseZxService;
	@Autowired
	private BaseUtils baseUtils;
	@Autowired
	private O2oLoanUserService o2oLoanUserService;
	/**
	 * @author CXW
	 * @describe  loan-13095 贷后管理增加贷后回检功能 ,详情页面
	 * @param entity
	 * @date 2018-03-01 16:12
	 * @return
	 */
	@RequestMapping("/pick_detail")
	public String afterLoanPickDetail(String loanapplyNo) {
		ViewContext.put(MenuTag.CURRENT_MENU_CODE, "afterLoanPickDetail");
		O2oLoanapplyEntity loanapply = loanService.findById(loanapplyNo);
		ViewContext.put("loanapply", loanapply);
		O2oEnterpriseZxEntity O2oEnterpriseZxEntity = o2oEnterpriseZxService.getEntityByloanapply(loanapply.getLoanapplyNo());
		ViewContext.put("O2oEnterpriseZxEntity", O2oEnterpriseZxEntity);
		String agreeUrl = baseUtils.getApprovalAgreeUrl(loanapply.getLoanapplyNo(), null, SystemModule.SYSTEM_MODULE_O2O);
		ViewContext.put("agreeUrl", agreeUrl);
		O2oLoanUserEntity loanUser = o2oLoanUserService.findById(loanapply.getLoanId(), loanapply.getLoanapplyNo());
		O2oLoanUserEntity materEntity = o2oLoanUserService.findSpouseId(loanapply.getLoanId(), loanapply.getLoanapplyNo());
		// =================借款人/配偶征信报告 begin=================
		String userZxId = "";
		String mateZxId = "";
		if (loanUser != null) {
			userZxId = loanUser.getZxNo();
		}
		if (materEntity != null) {
			mateZxId = materEntity.getZxNo();
		}
		ViewContext.put("userZxId", userZxId);
		ViewContext.put("mateZxId", mateZxId);
		return "afterloan/after_loan_pick_detail";
	}
}
